import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 产品表名映射信息 */
export interface ProductTableMapping {
          productId: string; // 产品id
          tableName?: string; // 表名
          type?: string; // 类型：daily/file
          timeField: string; // 时间戳类型字段，需要转换为日期
          ignoreField: string; // 忽略存储到数据库的字段
          remark: string; // 备注
  }

// 产品表名映射 API
export const ProductTableMappingApi = {
  // 查询产品表名映射分页
  getProductTableMappingPage: async (params: any) => {
    return await request.get({ url: `/business/product-table-mapping/page`, params })
  },

  // 查询产品表名映射详情
  getProductTableMapping: async (id: number) => {
    return await request.get({ url: `/business/product-table-mapping/get?id=` + id })
  },

  // 新增产品表名映射
  createProductTableMapping: async (data: ProductTableMapping) => {
    return await request.post({ url: `/business/product-table-mapping/create`, data })
  },

  // 修改产品表名映射
  updateProductTableMapping: async (data: ProductTableMapping) => {
    return await request.put({ url: `/business/product-table-mapping/update`, data })
  },

  // 删除产品表名映射
  deleteProductTableMapping: async (id: number) => {
    return await request.delete({ url: `/business/product-table-mapping/delete?id=` + id })
  },

  /** 批量删除产品表名映射 */
  deleteProductTableMappingList: async (ids: number[]) => {
    return await request.delete({ url: `/business/product-table-mapping/delete-list?ids=${ids.join(',')}` })
  },

  // 导出产品表名映射 Excel
  exportProductTableMapping: async (params) => {
    return await request.download({ url: `/business/product-table-mapping/export-excel`, params })
  }
}